import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/authredirect', component: () => import('@/views/login/authredirect'), hidden: true },
  { path: '/404', component: () => import('@/views/errorPage/404'), hidden: true },
  { path: '/401', component: () => import('@/views/errorPage/401'), hidden: true },
  {
    path: '/',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      name: 'dashboard',
      meta: { title: 'dashboard', icon: 'dashboard', noCache: true }
    }]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  {
    path: '/admin/channelconfig',
    component: Layout,
    children: [{ path: 'index', component: () => import('@/views/system/channelconfig/index'), name: '短信通道管理', meta: { title: '短信通道管理', icon: 'international' }}]
  },
  {
    path: '/admin/app',
    component: Layout,
    children: [{ path: 'index', component: () => import('@/views/system/app/index'), name: '应用管理', meta: { title: '应用管理', icon: 'international' }}]
  },
  {
    path: '/admin/template',
    component: Layout,
    children: [{ path: 'index', component: () => import('@/views/system/template/index'), name: '模板管理', meta: { title: '模板管理', icon: 'international' }}]
  },
  {
    path: '/admin/template',
    component: Layout,
    children: [{ path: 'index', component: () => import('@/views/system/history/index'), name: '发送记录', meta: { title: '发送记录', icon: 'international' }}]
  },
  {
    path: '/admin/debug',
    component: Layout,
    children: [{ path: 'index', component: () => import('@/views/system/debug/index'), name: '短信测试', meta: { title: '短信测试', icon: 'international' }}]
  },
  {
    path: '/admin/SendSmsException',
    component: Layout,
    children: [{ path: 'index', component: () => import('@/views/system/SendSmsException/index'), name: '异常管理', meta: { title: '异常管理', icon: 'international' }}]
  },
  {
    path: '/admin',
    component: Layout,
    redirect: 'noredirect',
    name: '系统管理',
    meta: {
      title: '系统管理',
      icon: 'chart'
    },
    children: [
      { path: 'user', component: () => import('@/views/system/user/index'), name: '用户管理', meta: { title: '用户管理', noCache: true }},
      { path: 'role', component: () => import('@/views/system/role/index'), name: '角色管理', meta: { title: '角色管理', noCache: true }},
      { path: 'menu', component: () => import('@/views/system/menu/index'), name: '菜单管理', meta: { title: '菜单管理', noCache: true }}
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
